﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<DrugStore.Helper.PaginateList<DrugStore.Models.News>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Quản lý tin tức
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="server">
    <h2>Quản lý tin tức</h2>
     <table cellpadding="0" cellspacing="0" class="data">
         <thead>
                <tr class="data">
                    <th class="data" width="350px" scope="col">
                        <a href="#">Tiêu đề</a>
                    </th>
                    <th class="data" width="200px">
                        <a href="#">Ngày tạo</a>
                    </th>
                    <th class="data" width="150px">
                        <a href="#">Danh mục</a>
                    </th>
                    <th class="data" width="100px"></th>
                </tr>            
            </thead>
            <tbody>
                <%foreach (DrugStore.Models.News n in Model)
                    {
                %>
                    <tr>
                        <td width="250px" ><%: n.Title %></td>
                        <td width="250px"><%: n.DateCreate %></td>
                        <td width="250px">
                            <% for (int i = 0; i < n.Categories.Count; i++ )
                               { %>
                                    <%: n.Categories.ElementAt(i).Name %><% if (i < (n.Categories.Count - 1)){%>, <% } %>
                            <% } %>
                        </td>
                        <td>
                            <p>
                                <%: Html.ActionLink("Sửa", "Edit", new { id =n.NewsId })%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <%:Html.ActionLink("Xóa", "Delete", new {id = n.NewsId })%> 
                            </p>                     
                        </td>
                    </tr>
                <% }%>
            </tbody>
    </table>   
    <div class="pagination">        
            <% if (Model.HasPreviousPage)
               { %><%:Html.ActionLink("Trang Đầu", "Index", new { pageindex = 1, keyword = Model.KeyWord })%>
               <%} %>
            <% if (Model.HasPreviousPage)
            { %><%:Html.ActionLink("Trang Trước", "Index", new { pageindex = (Model.PageIndex-1), keyword = Model.KeyWord })%>
            <%} %>
            Trang <%: Model.PageIndex %> / <%: Model.TotalPages %>
            <% if (Model.HasNextPage)
            { %><%:Html.ActionLink("Trang Tiếp", "Index", new { pageindex = (Model.PageIndex+1), keyword = Model.KeyWord })%>
            <%} %>
            <% if (Model.HasNextPage)
            { %><%:Html.ActionLink("Trang Cuối", "Index", new { pageindex = Model.TotalPages, keyword = Model.KeyWord })%>
            <%} %>  
    
    <div style="float:right;">
        <a href="/ManageNews/AddCategory">Thêm Danh mục tin</a>  <a href="/ManageNews/Add">Thêm tin mới</a>       
    </div>
    </div>
</asp:Content>
